<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			class Person {
				constructor(name, age) {
					this.name = name;
					this.age = age;
				}
				eat() {
					console.log('吃饭');
				}
			}

			class Student extends Person {
				constructor(name, age, score) {
					// this.name = name;
					// this.age = age;
					super(name, age); //调用父类的构造方法
					this.score = score;
				}
				//重写
				eat(){
					super.eat();//调用父类中的方法
					console.log('吃大餐');
				}						
				study() {
					console.log('学习');
				}
			}

			class Worker extends Person{
				constructor(name, age, hour) {
					// this.name = name;
					// this.age = age;
					super(name, age); //调用父类的构造方法
					this.hour = hour;
				}
				// eat(){
				// 	console.log('吃快餐');
				// }	
				work() {
					console.log('工作');
				}
			}

			const stu = new Student('张三', 20, 99);
			stu.eat();
		</script>
	</body>
</html>
